package com.example.item01.controller;

import com.example.item01.proj.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

@Slf4j
@RestController
public class UploadController {

@PostMapping("/upload")
    public Result  upload(String username, Integer age, MultipartFile image) throws IOException {
        log.info("文件上传:{} ,{} ,{}",username,age,image);
    String substring = image.getOriginalFilename().substring(image.getOriginalFilename().lastIndexOf("."));
    String path1 = UUID.randomUUID() + substring;
    image.transferTo(new File("D:\\zhaoyuan\\Documents\\"+path1));
    return Result.success();
    }
}









